package com.hs.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.bean.Role;
import com.hs.service.DeptService;
import com.hs.service.RoleService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
*
 *                                               __-------~~~~~~~~~~~------___
 *                                 / .  .   ~~//` ......          __--~ ~~
 *                   -.            \_|//     |||\\  ~~~~~~::::... /~
 *                ___-==_       _-~o~  \/    |||  \\            _/~~-
 *        __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *    _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *  .~       .~       |   \\ -_    /  /-   /   ||      \   /
 * /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 * |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~——__     .\
 *          '         ~-|      /|    |-~\~~       __--~~
 *                      |-~~-_/ |    |   ~\_   _-~            /\
 *                           /  \     \__   \/~                \__
 *                       _--~ _/ | .-~~____--~-/                  `~~==.
 *                      ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                 -_     ~\      ~~---l__i__i__i--~~_/
 *                                 _-~-__   ~)  \--______________--~~
 *                               //.-~~~-~_--~- |-------~~~~~~~~
 *                                      //.-~~~--\
 *                               神兽保佑
 *                              代码无BUG!
*/
@Controller
@RequestMapping("/resource/demo3")
public class RoleController {
    @Resource
    private RoleService roleService;
    @Resource
    private DeptService deptService;
    @RequestMapping("/all")
    public String select(Role role,Model model,Integer pageNum){
        if (pageNum==null || pageNum==0){
            pageNum=1;
        }

        PageHelper.startPage(pageNum, 3);
        List<Role> roles = roleService.selectBychoose(role);
        PageInfo<Role> pageInfo = new PageInfo<>(roles);
        model.addAttribute("page",pageInfo);
        model.addAttribute("roles",roles);
        return "resource/demo3/list";
    }

}
